package nju.bean.meeting.meetingManagement;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.HashMap;

import junit.framework.TestCase;

import nju.bean.meeting.data.User;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class MainMeetingManagerTest02 extends TestCase{
	MainMeetingManager mainMag;
	User user;
	@Before
	public void setUp() throws Exception {
		mainMag=MainMeetingManager.getInstance();
		user = new User("software","1","male","Microsoft","PM","123@123.com");
		
	} 

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testGetInstance() {
		MainMeetingManager actualMag=MainMeetingManager.getInstance();
		assertEquals(mainMag, actualMag);
	}

	@Test
	public void testNewMeeting() {
		HashMap<String, Object> actual= mainMag.newMeeting("SCS01", 2, user);		
		assertNotNull(actual);	
	}
    
	@Test
    public void testGetMeetingMgrList(){
		ArrayList<MeetingManager> actualList= mainMag.getMeetingMgrList();
		assertNotNull(actualList);		
    }
	
//	@Test
//	public void testEndMeeting() {
//		ArrayList<MeetingManager> magList= mainMag.getMeetingMgrList();		
//		mainMag.newMeeting("SCS03", 3, user);		
//		MeetingManager mm = magList.get(magList.size()-1);
//		System.out.println(mm.getMeeting().getName());
//		try {
//			mm.leaveMeeting(user.getUserName());
//		} catch (MeetingOverException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		assertTrue(mainMag.endMeeting(mm));
//	}

	@Test
	public void testMatchMeeting() {
		ArrayList<MeetingManager> magList= mainMag.getMeetingMgrList();
		HashMap<String, Object> hashmap= mainMag.newMeeting("SCS04", 4, user);		
		String mid = (String) hashmap.get("mId");
		MeetingManager mm = magList.get(magList.size()-1);
		MeetingManager actualMm = mainMag.matchMeeting(mid);
		assertEquals(mm, actualMm);
	}
		
		
//
//	@Test
//	public void testDealBreak() {
//		mainMag.newMeeting("SCS05", 5, user);
//		assertTrue(mainMag.dealBreak(user.getUserName()));
//	}

}
